import { request } from "./request";
/* export function getToken(){
    return request({
        baseURL: "/api/auth/common",
    })
} */
export function Wby_login(data:any){  //微北洋登录
    return request({
        url: "/auth/login/jwt",
        method: "get",
        params: data,
    })
}
export function email_login(data:any){  //邮箱登录
    return request({
        url: "auth/login/email",
        method: "post",
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}
export function getEmailCode(data:any){  //获取验证码
    return request({
        url: "auth/email/code",
        method: "get",
        params: data,
    })
}
export function registerEmail(data:any){ //绑定邮箱
    return request({
        url: "auth/register",
        method: "post",
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}
export function getNotice(){  //获取通知
    return request({
        url: "auth/notice/get",
        method: "get",
    })
}
export function findPassword(data:any){ //找回密码
    return request({
        url: "auth/findpassword",
        method: "post",
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}
export function readNotice(data:any){  //读通知
    return request({
        url: "auth/notice/read",
        method: "post",
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}
export function getPrivateCapsual(data:any){  //获取所有私有胶囊
    return request({
        url: "/capsule/private/list",
        method: "get",
        params: data,
    })
}
export function openOneCapsual(data:any){  //首次打开一个私有胶囊
    return request({
        url: "/capsule/private/open",
        method: "get",
        params: data,
    })
}
export function getOpenedCapsualInfo(data:any){  //获取一个已经打开过的胶囊的信息
    return request({
        url: "/capsule/private/content",
        method: "get",
        params: data,
    })
}
export function addPrivateCapsual(data:any){  //新建私有胶囊
    return request({
        url: "/capsule/private/add",
        method: "post",
        data,
    })
}
export function addPublicCapsual(data:any){  //新建公共胶囊
    return request({
        url: "capsule/public/add",
        method: "post",
        data,
    })
}
export function giveLikePublicCapsual(data:any){  //点赞公共胶囊
    return request({
        url: "capsule/public/like",
        method: "get",
        params: data,
    })
}
export function reportPublicCapsual(data:any){  //举报公共胶囊
    return request({
        url: "capsule/public/report",
        method: "post",
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}
export function getReportedCapsule() {
    return request({
        url: "admin/report",
        method: "get",
    })
}
export function getAllPublicCapsual(data:any){  //获取胶囊池下的公共胶囊
    return request({
        url: "capsule/public/list",
        method: "get",
        params: data,
    })
}
export function alterPubliCapsual(data:any){  //修改公共胶囊
    return request({
        url: "capsule/public/alter",
        method: "post",
        data,
    })
}
export function deletePublicCapsual(data:any){ //删除公共胶囊
    return request({
        url: "capsule/public/delete",
        method: "get",
        params: data,
    })
}
export function addPool(data:any){  //新建胶囊池
    return request({
        url: "pool/add",
        method: "post",
        data,
    })
}
export function openPool(data:any){  //开启胶囊池
    return request({
        url: "pool/open",
        method: "get",
        params: data,
    })
}
export function closePool(data:any){  //关闭某个胶囊池
    return request({
        url: "pool/close",
        method: "get",
        params: data,
    })
}
export function getOnePoolInfo(data:any){  //获取一个胶囊池的信息
    return request({
        url: "pool/one",
        method: "get",
        params: data,
    })
}
export function getAllPoolInfo(data:any){  //获取所有胶囊池信息
    return request({
        url: "pool/list",
        method: "get",
        params: data,
    })
}
export function deletePool(data:any){  //删除胶囊池
    return request({
        url: "pool/delete",
        method: "get",
        params: data,
    })
}
export function twt_login(data:any,header:any){  //登录页使用账号密码登录
    return request({
        baseURL: "https://api.twt.edu.cn/api/",
        url: "auth/common",
        method: "post",
        data: data,
        headers: header,
    })
}
export function loadImage(data:any,header:any){
    return request({
        baseURL: "/apis",
        url: "/api/v2/upload",
        method: "post",
        data: data,
        headers: header,
        transformRequest: [function(data,headers) {
            if(headers){
                delete headers['Content-Type']
                return data    
            }
        }]
    })
}
export function getImageToken(data:any){
    return request({
        baseURL: "/apis",
        url: "/api/v2/token",
        method: "post",
        data: data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}
export function getFile(path:string) {
    return request({
        url: `file/${path}`,
        method: "get",
        responseType: "arraybuffer",
    });
}
export function uploadFile(file: any) {
    return request({
        url: "file/upload",
        method: "post",
        data: file,
        headers: {
            'Content-Type': 'multipart/form-data'  /* 不做qs或json处理 */
        }
    });
}
